//
//  GKNovelSet.swift
//  MySwiftObject
//
//  Created by wangws1990 on 2019/9/12.
//  Copyright © 2019 wangws1990. All rights reserved.
//

import UIKit
import HandyJSON
enum GKNovelState : Int{
    case defaults = 0;
    case green = 1;
    case caffee = 2;
    case pink = 3;
    case fen = 4;
    case zi = 5;
    case yellow = 6;
}
enum GKNovelBrowse : Int{
    case defaults = 0;
    case pageCurl = 1;
    case none = 2;
}
class GKNovelSet: BaseModel,NSCoding {
    func encode(with aCoder: NSCoder) {
        aCoder.encode(color, forKey: "color")
        aCoder.encode(fontName, forKey: "fontName")
        aCoder.encode(font, forKey: "font")
        aCoder.encode(lineSpacing, forKey: "lineSpacing")
        aCoder.encode(firstLineHeadIndent, forKey: "firstLineHeadIndent")
        
        aCoder.encode(paragraphSpacingBefore, forKey: "paragraphSpacingBefore")
        aCoder.encode(paragraphSpacing, forKey: "paragraphSpacing")
        aCoder.encode(brightness, forKey: "brightness")
        
        aCoder.encode(night, forKey: "night")
        aCoder.encode(landscape, forKey: "landscape")
        aCoder.encode(traditiona, forKey: "traditiona")
        
        aCoder.encode(skin.rawValue, forKey: "skin")
        aCoder.encode(browse.rawValue, forKey: "browse")
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init()
        color = aDecoder.decodeObject(forKey: "color") as! String?
        fontName =  aDecoder.decodeObject(forKey: "fontName") as! String?
        font = aDecoder.decodeObject(forKey: "font") as! Float?
        
        lineSpacing = aDecoder.decodeObject(forKey: "lineSpacing") as! Float?
        firstLineHeadIndent = aDecoder.decodeObject(forKey: "firstLineHeadIndent") as! Float?
        paragraphSpacingBefore = aDecoder.decodeObject(forKey: "paragraphSpacingBefore") as! Float?
        paragraphSpacing = aDecoder.decodeObject(forKey: "paragraphSpacing") as! Float?
        brightness = aDecoder.decodeObject(forKey: "brightness") as! Float?
            
        night = aDecoder.decodeObject(forKey: "night") as! Bool?
        landscape = aDecoder.decodeObject(forKey: "landscape") as! Bool?
        traditiona = aDecoder.decodeObject(forKey: "traditiona") as! Bool?
        
        browse = GKNovelBrowse(rawValue: Int(aDecoder.decodeInt32(forKey:"browse")))
        skin = GKNovelState(rawValue: Int(aDecoder.decodeInt32(forKey:"skin")))
    }
    
    required init() {
//        fatalError("init() has not been implemented")
    }
    
    
    var color:String!;
    var fontName:String!;
    var font : Float!;
    var lineSpacing :Float!;
    var firstLineHeadIndent : Float!;
    var paragraphSpacingBefore :Float!;
    var paragraphSpacing : Float!;
    var brightness :Float!;
    
    var night :Bool!;
    var landscape :Bool!;
    var traditiona :Bool!;
    
    var skin :GKNovelState!;
    var browse :GKNovelBrowse!;
    
}
class GKNovelSkin: HandyJSON {
    var title:String!;
    var skin:String!;
    var state :GKNovelState!;
    class func vcWithModel(title:String,skin:String,state:GKNovelState) -> GKNovelSkin{
        let vc:GKNovelSkin = self.init();
        vc.title = title;
        vc.skin = skin;
        vc.state = state;
        return vc;
    }
    required init() {}
}
